package com.itheima.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Demo04 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable my = new MyCallable();
        FutureTask<String> task = new FutureTask<>(my);
        FutureTask<String> task2 = new FutureTask<>(my);
        Thread t1 = new Thread(task);
        Thread t2 = new Thread(task2);
        t1.start();
        t2.start();
        String s = task.get();//get 死等 ,等到结果才走
        System.out.println(s);
        String s1 = task2.get();
        System.out.println(s1);
       /* for (int i = 0; i < 100; i++) {
            System.out.println("main线程执行到了"+i);
        }*/



    }
}
